using System;
using AntEater.ComponentModel.Validation;
using System.ComponentModel;
using System.Collections.ObjectModel;
using AntEater.ComponentModel.BuildElements.Design;
using System.Drawing.Design;

namespace AntEater.ComponentModel.BuildElements
{
    /// <summary>
    /// Provides the ProjectExtensions build element.
    /// </summary>
    [Serializable]
    [BuildElement("ProjectExtensions")]
    [Icon(typeof(ProjectExtensionBuildElement), "AntEater.ComponentModel.Resources.ProjectExtension.ico")]
    public class ProjectExtensionBuildElement : BuildElementBase
    {

        /// <summary>
        /// Initializes a new instance of the <see cref="T:ProjectExtensionBuildElement"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        public ProjectExtensionBuildElement(BuildFileDefinition context)
            : base(context) {
        }

        private string _content;

        /// <summary>
        /// Gets or sets the content.
        /// </summary>
        /// <value>The content.</value>
        [BuildElementProperty("Content", false, BuildElementPropertyType.Xml)]
        [Description("Raw Xml passed to the IDE.")]
        [DisplayName("Xml")]
        [Category("MsBuild")]
        [Editor(typeof(TextTypeEditor), typeof(UITypeEditor))]
        [ToolTip()]
        public string Content {
            get { return _content; }
            set {
                if (_content != value) {
                    _content = value;
                    OnPropertyChanged("Content");
                }
            }
        }

        /// <summary>
        /// Determines whether this instance is valid.
        /// </summary>
        /// <value></value>
        /// <returns>
        /// 	<c>true</c> if this instance is valid; otherwise, <c>false</c>.
        /// </returns>
        public override bool IsValid {
            get { throw new NotImplementedException(); }
        }

        /// <summary>
        /// Validates the specified recursive.
        /// </summary>
        /// <param name="recursive">if set to <c>true</c> [recursive].</param>
        /// <returns></returns>
        public override ReadOnlyCollection<ValidationResult> Validate(bool recursive) {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public override object Clone() {
            ProjectExtensionBuildElement newElement = base.Clone() as ProjectExtensionBuildElement;

            if (this._content != null) {
                newElement._content = this._content.Clone() as string;
            }

            return newElement;
        }
    }
}
